package yl.hs.bmipfull.daos.production;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import yl.hs.bmipfull.daos.BaseDao;
import yl.hs.bmipfull.pojo.production.FinishProductInventoryEntity;
import yl.hs.bmipfull.viewmodels.chart.BrandInventoryModel;

import java.util.List;
import java.util.Map;

/**
 * @author 谢东
 * @apiNote 成品仓库库存持久层接口
 * @since 2023年06月14日 15时02分03秒
 */
@Repository
public interface IFinishProductInventoryDao extends BaseDao<FinishProductInventoryEntity> {


    /**
     * 分页查询成品仓库库存信息
     *
     * @param map 查询条件 {@link FinishProductInventoryEntity}
     * @return 站内信息-List<{@link FinishProductInventoryEntity}>
     */
    List<FinishProductInventoryEntity> queryPage(@Param("map") Map<String, Object> map);

    /**
     * 根据查询条件统计数据数量
     *
     * @param map 查询条件
     * @return 数据数量
     */
    Integer queryCountByCondition(@Param("map") Map<String, Object> map);

    /**
     * 根据成品仓库库存编号更改成品仓库库存信息状态
     *
     * @param snArray 成品仓库库存编号
     * @param state   要改变的状态
     * @return 执行结果
     */
    Integer changeStateBySN(String[] snArray, short state);

    @Select("select * from finish_product_inventory where productSN=#{productSN} and wareHouseSN=#{wareHouseSN} and packageName=#{packageName} and packageSN=#{packageSN} and state>=0 limit 1")
    FinishProductInventoryEntity findByWareHouseSNAndProductSN(String wareHouseSN,String productSN,String packageName,String packageSN);
    @Select("select * from finish_product_inventory where productSN=#{productSN}  and packageName=#{packageName} and packageSN=#{packageSN} and state>=0")
    List<FinishProductInventoryEntity> findByProductSN(String productSN,String packageName,String packageSN);
    @Select("select * from finish_product_inventory where productSN=#{productSN}  and packageName=#{packageName} and packageSN=#{packageSN} and wareHouseSN = #{wareHouseSN} and state>=0 limit 1")
    List<FinishProductInventoryEntity> findByProductSNAndWareHouseSN(String productSN,String packageName,String packageSN,String wareHouseSN);
    @Select("select * from finish_product_inventory where productSN=#{productSN}  and state>=0")
    List<FinishProductInventoryEntity> quantityByProductSN(String productSN);
    List<BrandInventoryModel> queryBrandInventory();
    List<BrandInventoryModel> queryBrandByCateName(String cateSN);
    @Select("select * from finish_product_inventory where state>=0")
    List<FinishProductInventoryEntity> queryAll();
}